package com.iyoudoock.citymine.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.iyoudoock.citymine.R;
import com.iyoudoock.citymine.bean.DistrictBean;
import com.kvin.toolkit.adapter.BasicRecyclerAdapter;

import java.util.List;

/**
 * Created by Kvin on 2017/6/6.
 */
public class DistrictListAdapter extends BasicRecyclerAdapter<DistrictBean, DistrictListAdapter.ViewHolder> {
    public DistrictListAdapter(List<DistrictBean> items, Context context) {
        super(items, context);
    }

    @Override
    protected View bindConvertView(LayoutInflater layoutInflater, ViewGroup parent, int i) {
        return inflater.inflate(R.layout.adapter_district_list, parent, false);
    }

    @Override
    protected ViewHolder bindHolder(View v) {
        return new ViewHolder(v);
    }

    @Override
    protected void bindData(List<DistrictBean> list, ViewHolder holder, int position) {
        DistrictBean b = list.get(position);
        holder.nameTv.setText(b.getVillageName());
        holder.nameTv.setTag(position);
        holder.nameTv.setOnClickListener(this);
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView nameTv;

        public ViewHolder(View itemView) {
            super(itemView);
            nameTv = (TextView) itemView.findViewById(R.id.name_tv);
        }
    }
}
